//
//  RegisteViewController.m
//  Matador
//
//  Created by leaf on 15/10/7.
//  Copyright © 2015年 MicroGolds. All rights reserved.
//

#import "RegisteViewController.h"

@interface RegisteViewController () {
    UITextField *_phoneField;
    UITextField *_passwordField;
    UITextField *_verifyField;
    
    UIButton *_verifyBtn;
    
    UIButton *_registeBtn;
}

@end

@implementation RegisteViewController

#pragma mark - Methods
- (void)backgroundTapped:(id)sender {
    [self.view endEditing:YES];
}
#pragma mark - View Control
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"注册";
    
    UIControl *ctrl = [[UIControl alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
    ctrl.backgroundColor = [UIColor lightGrayColor];
    [ctrl addTarget:self action:@selector(backgroundTapped:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:ctrl];
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 20, ScreenHeight, ScreenHeight - 20)];
    view.backgroundColor = [UIColor whiteColor];
    view.userInteractionEnabled = NO;
    [self.view addSubview:view];
    
    UIImageView *phoneIcon = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, MTDFloat(65), MTDFloat(65))];
    phoneIcon.left = MTDFloat(42);
    phoneIcon.centerY = 20 + MTDFloat(192) * 0.5f;
    phoneIcon.image = [UIImage imageNamed:@"login_phone_icon"];
    [self.view addSubview:phoneIcon];
    
    UITextField *phoneField = [[UITextField alloc] initWithFrame:CGRectMake(0, 20, ScreenWidth - phoneIcon.right - MTDFloat(42) - 10, MTDFloat(192))];
    phoneField.left = phoneIcon.right + MTDFloat(42);
    phoneField.backgroundColor = [UIColor clearColor];
    phoneField.textColor = [UIColor blackColor];
    phoneField.font = [UIFont systemFontOfSize:20];
    phoneField.borderStyle = UITextBorderStyleNone;
    phoneField.adjustsFontSizeToFitWidth = NO;
    phoneField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    phoneField.autocorrectionType = UITextAutocorrectionTypeNo;
    phoneField.autocapitalizationType = UITextAutocapitalizationTypeNone;
    phoneField.returnKeyType = UIReturnKeyDone;
    phoneField.clearButtonMode = UITextFieldViewModeWhileEditing;
    phoneField.keyboardType = UIKeyboardTypePhonePad;
    phoneField.placeholder = @"请输入手机号码";
    [self.view addSubview:phoneField];
    
    _phoneField = phoneField;
    
    {
        UIView *line = [[UIView alloc] initWithFrame:CGRectMake(phoneIcon.left, phoneField.bottom, ScreenWidth - phoneIcon.left, 0.5f)];
        line.backgroundColor = [UIColor lightGrayColor];
        [self.view addSubview:line];
    }
    
    UIImageView *passwordIcon = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, MTDFloat(65), MTDFloat(65))];
    passwordIcon.left = MTDFloat(42);
    passwordIcon.centerY = phoneField.bottom + MTDFloat(192) * 0.5f;
    passwordIcon.image = [UIImage imageNamed:@"login_password_icon"];
    [self.view addSubview:passwordIcon];
    
    UITextField *passwordField = [[UITextField alloc] initWithFrame:CGRectMake(0, phoneField.bottom, ScreenWidth - phoneIcon.right - MTDFloat(42) - 10, MTDFloat(192))];
    passwordField.left = passwordIcon.right + MTDFloat(42);
    passwordField.backgroundColor = [UIColor clearColor];
    passwordField.textColor = [UIColor blackColor];
    passwordField.font = [UIFont systemFontOfSize:20];
    passwordField.borderStyle = UITextBorderStyleNone;
    passwordField.adjustsFontSizeToFitWidth = NO;
    passwordField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    passwordField.autocorrectionType = UITextAutocorrectionTypeNo;
    passwordField.autocapitalizationType = UITextAutocapitalizationTypeNone;
    passwordField.returnKeyType = UIReturnKeyDone;
    passwordField.clearButtonMode = UITextFieldViewModeWhileEditing;
    passwordField.keyboardType = UIKeyboardTypeDefault;
    passwordField.secureTextEntry = YES;
    passwordField.placeholder = @"请输入密码";
    [self.view addSubview:passwordField];
    
    _passwordField = passwordField;
    
    {
        UIView *line = [[UIView alloc] initWithFrame:CGRectMake(passwordIcon.left, passwordField.bottom, ScreenWidth - passwordIcon.left, 0.5f)];
        line.backgroundColor = [UIColor lightGrayColor];
        [self.view addSubview:line];
    }
    
    UIImageView *verifyIcon = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, MTDFloat(65), MTDFloat(65))];
    verifyIcon.left = MTDFloat(42);
    verifyIcon.centerY = passwordField.bottom + MTDFloat(192) * 0.5f;
    verifyIcon.image = [UIImage imageNamed:@"registe_verify_icon"];
    [self.view addSubview:verifyIcon];
    
    UITextField *verifyField = [[UITextField alloc] initWithFrame:CGRectMake(0, passwordField.bottom, ScreenWidth - verifyIcon.right - MTDFloat(42) - 10 - MTDFloat(53) - MTDFloat(53) - MTDFloat(250), MTDFloat(192))];
    verifyField.left = verifyIcon.right + MTDFloat(42);
    verifyField.backgroundColor = [UIColor clearColor];
    verifyField.textColor = [UIColor blackColor];
    verifyField.font = [UIFont systemFontOfSize:20];
    verifyField.borderStyle = UITextBorderStyleNone;
    verifyField.adjustsFontSizeToFitWidth = NO;
    verifyField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    verifyField.autocorrectionType = UITextAutocorrectionTypeNo;
    verifyField.autocapitalizationType = UITextAutocapitalizationTypeNone;
    verifyField.returnKeyType = UIReturnKeyDone;
    verifyField.clearButtonMode = UITextFieldViewModeWhileEditing;
    verifyField.keyboardType = UIKeyboardTypePhonePad;
    verifyField.placeholder = @"填写验证码";
    [self.view addSubview:verifyField];
    
    _verifyField = verifyField;
    
    UIButton *verifyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    verifyBtn.frame = CGRectMake(verifyField.right + MTDFloat(53), 0, MTDFloat(250), MTDFloat(101));
    verifyBtn.centerY = verifyField.centerY;
    [verifyBtn.titleLabel setFont:[UIFont systemFontOfSize:14]];
    [verifyBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [verifyBtn setTitle:@"发送验证码" forState:UIControlStateNormal];
    [verifyBtn setBackgroundImage:[UIImage imageNamed:@"registe_verify_btn"] forState:UIControlStateNormal];
    [self.view addSubview:verifyBtn];
    
    _verifyBtn = verifyBtn;
    
    {
        UIView *line = [[UIView alloc] initWithFrame:CGRectMake(verifyIcon.left, verifyField.bottom, ScreenWidth - verifyIcon.left, 0.5f)];
        line.backgroundColor = [UIColor lightGrayColor];
        [self.view addSubview:line];
    }
    
    UIFont *font = [UIFont systemFontOfSize:20];
    
    UIButton *registeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    registeBtn.frame = CGRectMake(0, 0, MTDFloat(554), MTDFloat(157));
    registeBtn.left = MTDFloat(53);
    registeBtn.top = verifyField.bottom + MTDFloat(66);
    [registeBtn.titleLabel setFont:font];
    [registeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [registeBtn setTitle:@"注册" forState:UIControlStateNormal];
    [registeBtn setBackgroundImage:[UIImage imageNamed:@"login_login_btn"] forState:UIControlStateNormal];
    [self.view addSubview:registeBtn];
    
    _registeBtn = registeBtn;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
